home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_5.lha / 8_5 / fgets.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  463b  |  25 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / read a string up to and including a newline
  6. include <string.h>
  7. har *fgets(char *buf, int length, FILE *f)
  8.  
  9.    if ((f->mode == input) &&
  10. (f->in->get(buf, length-2)))
  11. {
  12. char c = 0;
  13. f->in->get(c);
  14. if (c == '\n')
  15.     {
  16.     char *nl = buf + strlen(buf);
  17.     *nl++ = '\n';
  18.     *nl = 0;
  19.     }
  20. return buf;
  21. }
  22.  
  23.    return NULL;
  24.  
  25.